define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	
	$scope.form.father_id=params.father_id;

	//查询所有单位
	httpService.post(app.urls.unit_selectCenterAndSchool,{},function(data){
		if("0000" === data.code){
			$scope.units = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询教职工类别
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10235"},function(data){
		if("0000" === data.code){
			$scope.jzglbms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询性别码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA29"},function(data){
		if("0000" === data.code){
			$scope.xbms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询民族代码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10002"},function(data){
		if("0000" === data.code){
			$scope.mzms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询籍贯代码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA31"},function(data){
		if("0000" === data.code){
			$scope.hksfList = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询国别码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA35"},function(data){
		if("0000" === data.code){
			$scope.gjdqms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//身份证件类型
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10236"},function(data){
		if("0000" === data.code){
			$scope.gjdqms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询婚姻状况码 
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10012"},function(data){
		if("0000" === data.code){
			$scope.hyzkms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询查询政治面貌代码 
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10006"},function(data){
		if("0000" === data.code){
			$scope.zzmmms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询健康状况代码 
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10005"},function(data){
		if("0000" === data.code){
			$scope.jkzkms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询户口性质代码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10007"},function(data){
		if("0000" === data.code){
			$scope.hkxzms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询编制类别(国)
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA36"},function(data){
		if("0000" === data.code){
			$scope.bzlbms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询教师类别
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10223"},function(data){
		if("0000" === data.code){
			$scope.jslbms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询专技职务资格
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA130"},function(data){
		if("0000" === data.code){
			$scope.zjzwzgms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询所教学段
	httpService.post(app.urls.teacher_selectStage,{},function(data){
		if("0000" === data.code){
			$scope.sjxds = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询最高学位(学位代码)
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10023"},function(data){
		if("0000" === data.code){
			$scope.zgxws = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询外国语熟练程度码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA42"},function(data){
		if("0000" === data.code){
			$scope.zwwycds = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询专业分类
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA90"},function(data){
		if("0000" === data.code){
			$scope.zyflms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询宗教信仰代码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10003"},function(data){
		if("0000" === data.code){
			$scope.xyzjms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询血型代码
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10001"},function(data){
		if("0000" === data.code){
			$scope.xxms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询港澳台侨外
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10240"},function(data){
		if("0000" === data.code){
			$scope.gatqwms = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询最高学历 
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10225"},function(data){
		if("0000" === data.code){
			$scope.zgxls = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询职称
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"j0ufs4tghd299dc9ukl57era4asd3425"},function(data){
		if("0000" === data.code){
			$scope.zcList = data.data;
		}else{
			alert(data.msg);
		}
	});
	//查询拔尖人才
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"a3dfc4dfws254dc6rfg44fgc2dbg904"},function(data){
		if("0000" === data.code){
			$scope.bjList = data.data;
		}else{
			alert(data.msg);
		}
	});
	$scope.saveForm = function(){
 		if($scope.formCheck()) {
			$scope.form.type = '1';
			httpService.post(app.urls.teacher_selectRepeat,$scope.form,function(data) {
				if ("0000" === data.code) {
					// httpService.post(app.urls.user_insert,$scope.form,function(data) {
					// 	if ("0000" === data.code) {
					// 		$scope.form.id=$scope.form.fk_user = data.data;
							httpService.post(app.urls.teacher_insert, $scope.form, function (data) {
								if ("0000" === data.code) {
									$scope.form.fk_unit = $scope.form.gzdwpk;
									$scope.form.fk_user = data.data;
									httpService.post(app.urls.user_unit_insert, $scope.form, function (data) {
										if ("0000" === data.code) {
											$scope.form.type = '2';
											$scope.form.fk_unit = $scope.form.rsdwpk;
											httpService.post(app.urls.user_unit_insert,$scope.form, function (data) {
												if ("0000" === data.code) {
													httpService.post(app.urls.user_resetPwd,{"ids":$scope.form.fk_user,"type":'1'}, function(data) {
														if ("0000" === data.code) {
															var menu = {"url":"modules/content/usermanagement/teacherCenter/list?father_id="+params.father_id+"&gzdwpk="+$scope.form.gzdwpk+"&rsdwpk="+$scope.form.rsdwpk};
															eventBusService.publish("modules.content.load",menu);
														} else {
															alert(data.msg);
														}
													});	
												} else {
													alert(data.msg);
												}
											});
										} else {
											alert(data.msg);
										}
									});
								} else {
									alert(data.msg);
								}
							});
					// 	} else {
					// 		alert(data.msg);
					// 	}
					// });
				}else {
					alert(data.msg);
				}
			});	
 		}
	 }
	//返回
	$scope.goback = function(){
		var menu = {"url":"modules/content/usermanagement/teacherCenter/list?father_id="+params.father_id};
		eventBusService.publish("modules.content.load",menu);
	}
	 //日期插件
  	$('#'+$scope.controllerName+' .datepicker').datepicker({
  		onSelect: function(dateText, inst) {
 			eval("$scope." + $(this).attr('ng-model') + "='"+$(this).val()+"'");
         }
  	});
 	$('#'+$scope.controllerName+' .datepicker').datepicker('option', 'dateFormat','yy-mm-dd');//set dateFormat
}}});